package com.itboye.lottery.fragment;


import android.content.Intent;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.itboye.lottery.base.BaseFragment;
import com.itboye.lottery.R;
import com.itboye.lottery.activity.PlayMethodActivity;
import com.itboye.lottery.adapter.FindAdapter;

import java.util.ArrayList;
import java.util.HashMap;

/**
 * Created by Administrator on 2017/11/10.
 */

public class FindFragment extends BaseFragment {

    RecyclerView rv_fragment_find;
    private FindAdapter adapter;
    private ArrayList<HashMap<String, Object>> hashMapArrayList;

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_find;
    }

    @Override
    protected void initData() {
        //init
        initRecyclerViewData();
        adapter = new FindAdapter(initRecyclerViewData());
        rv_fragment_find.setLayoutManager(new LinearLayoutManager(getActivity()));
        rv_fragment_find.setAdapter(adapter);
        rv_fragment_find.addItemDecoration(new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL));
        adapter.setOnItemClickListener((view, position) -> {
            startActivity(new Intent(getActivity(), PlayMethodActivity.class)
                    .putExtra("position", position)
                    .putExtra("title", hashMapArrayList.get(position).get("title").toString()));
        });
    }

    private ArrayList<HashMap<String, Object>> initRecyclerViewData() {
        hashMapArrayList = new ArrayList<>();
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("title", "玩法大集");
        hashMap.put("content", "玩法大集");
        hashMap.put("icon", R.mipmap.wanfadaji);
        hashMapArrayList.add(hashMap);

        hashMap = new HashMap<>();
        hashMap.put("title", "新闻资讯");
        hashMap.put("content", "新闻资讯");
        hashMap.put("icon", R.mipmap.xinweizixun);
        hashMapArrayList.add(hashMap);

        hashMap = new HashMap<>();
        hashMap.put("title", "活动中心");
        hashMap.put("content", "活动中心");
        hashMap.put("icon", R.mipmap.huodongzhongxin);
        hashMapArrayList.add(hashMap);

        hashMap = new HashMap<>();
        hashMap.put("title", "公告中心");
        hashMap.put("content", "公告中心");
        hashMap.put("icon", R.mipmap.gonggaozhongxin);
        hashMapArrayList.add(hashMap);
        return hashMapArrayList;
    }

    @Override
    public void onClick(View view) {

    }
}
